package com.oig.sys.file.app.impl;

import com.oig.common.module.SysPageInfo;
import com.oig.common.module.SysRequest;
import com.oig.sys.file.app.IAppFileInfoService;
import com.oig.sys.file.dto.BusFileInfoDto;
import com.oig.sys.file.dto.FileInfoDto;
import com.oig.sys.file.service.ITbFileInfoService;
import com.oig.sys.file.vo.FileInfoVo;
import io.seata.spring.annotation.GlobalLock;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Slf4j
@Component
@RequiredArgsConstructor
public class AppFileInfoServiceImpl implements IAppFileInfoService {

    private final ITbFileInfoService fileInfoService;


    @Override
    public FileInfoVo addFileInfo(FileInfoDto fileInfoDto) {
        return this.fileInfoService.addFileInfo(fileInfoDto);
    }

    @GlobalLock
    @Override
    public FileInfoVo updateFileInfo(FileInfoDto fileInfoDto) {
        return this.fileInfoService.updateFileInfo(fileInfoDto);
    }

    @GlobalLock
    @Override
    public List<FileInfoVo> updateRelationAllFileInfo(BusFileInfoDto busFileInfoDto) {
        return this.fileInfoService.updateRelationAllFileInfo(busFileInfoDto);
    }

    @GlobalLock
    @Override
    public void delRelationAllFileInfo(BusFileInfoDto busFileInfoDto) {
        this.fileInfoService.delRelationAllFileInfo(busFileInfoDto);
    }

    @GlobalLock
    @Override
    public FileInfoVo cancelFileInfo(Integer id) {
        return this.fileInfoService.cancelFileInfo(id);
    }

    @GlobalLock
    @Override
    public void delFileInfo(Integer id) {
        this.fileInfoService.delFileInfo(id);
    }

    @Override
    public FileInfoVo getFileInfo(Integer id) {
        return this.fileInfoService.getFileInfo(id);
    }

    @Override
    public SysPageInfo<FileInfoVo> queryList(SysRequest<FileInfoDto> fileInfoRequest) {
        return this.fileInfoService.queryList(fileInfoRequest);
    }

    @Override
    public List<FileInfoVo> addBatchFile(List<FileInfoDto> fileInfoDtoList) {
        List<FileInfoVo> fileInfoVoList=new ArrayList<>();
        for (FileInfoDto fileInfoDto:fileInfoDtoList) {
            fileInfoVoList.add(fileInfoService.addFileInfo(fileInfoDto));
        }
        return fileInfoVoList;
    }

}
